package com.ali.memory;

import java.util.ArrayList;
import java.util.List;

public class FullGCDemo {

	public static void main(String[] args) throws InterruptedException {
		Thread.sleep(MemoObj.TIME_15_S);
		List<MemoObj> list = new ArrayList<MemoObj>(6);
		for (int i = 0; i < 10; ++i) {
			list.add(new MemoObj(MemoObj.SIZE_1_M));
			System.out.println("======>New MemoObj 1M be added to eden:" + i);
			Thread.sleep(MemoObj.TIME_1_S);
		}
		
		System.out.println();
		System.out.println("======>System.gc() by manual");
		System.gc();

		Thread.sleep(MemoObj.TIME_1_S * 2);

		list.clear();

		for (int i = 0; i < 10; ++i) {
			list.add(new MemoObj(MemoObj.SIZE_1_M));
			System.out.println("======>New MemoObj 1M be added to eden:" + i);
			if (i % 3 == 0) {
				list.remove(0);
			}
			Thread.sleep(MemoObj.TIME_1_S);
		}

		Thread.sleep(MemoObj.TIME_15_S);

	}

}
